﻿namespace Leetcode.N0942;
public class Solution
{
    public int[] DiStringMatch(string s)
    {
        int max = s.Length, min = 0;
        var perm = new int[s.Length + 1];

        for (int i = 0; i < s.Length; i++)
        {
            perm[i] = s[i] == 'I' ? min++ : max--;
        }

        perm[perm.Length - 1] = min;

        return perm;
    }
}